package jia.tools;

import jia.game.GenericFlags;
import org.apache.log4j.Logger;
import org.dom4j.io.SAXReader;
import org.dom4j.Document;
import org.dom4j.DocumentException;

import java.io.File;

/**
 * **************************************************************************
 * Application:
 * Author: Erik Stell
 * Date: Feb 8, 2005
 * Time: 12:20:19 PM
 * Process:
 * **************************************************************************
 */
public class TimelineEventGenerator {
    private static final Logger log = Logger.getLogger(TimelineEventGenerator.class);
    private static File fileToBeParsed = new File("src/com/gryffonx/xml/timeline.xml");
    private static SAXReader reader = new SAXReader();
    private static Document xmlDoc = null;
    
    public static String generateEvent(){
        String retVal = "";
        
        try {
            xmlDoc = reader.read(fileToBeParsed);
        } catch (DocumentException e) {
            if (GenericFlags.errorMessages){
                log.error(e.getMessage());
            }
        } catch (Exception e) {
            if (GenericFlags.errorMessages){
                log.error(e.getMessage());
            }
        }
        
        retVal = (StringUtils.capitalize(XMLUtils.getNodeValue("timeline", xmlDoc, 1)));
        
        return retVal;
        
    }
}
